<template>
  <div class="menu">
      <div class="chatNum">当前聊天室人数：12人</div>
    <div
      v-for="(item,index) in chatMenu"
      :key="index"
      class="Box"
      :class="{changeColor:currentIndex===index}"
      @click="changeIndex(index,item.roomId,item.username)"
    >
      <div class="leftItem">
        <img :src="item.avatar" alt="头像" />
      </div>
      <div class="rightItem">
        <p>{{item.realname}}</p>
        <p>{{item.message}}</p>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import {defineProps,ref,reactive} from "vue"
import {chatMenu} from "@/type/chat"
  const props =  defineProps({
    chatMenu: {
      type: Array,
      default() {
        return [];
      },
    },
  })
      const currentIndex = ref<number>(-1)
     const lastUsername =ref<string>("root")
     const initChat = reactive<Array<chatMenu>>([])
    const chatItem = reactive<Array<chatMenu>>([])//存储我和她之间的对话
    const changeIndex = (a:any,b:any,c:any)=>{

    }

</script>

<style lang="scss" scoped>
.changeColor {
  background-color: rgba(255, 255, 255, 0.6);
  color: #333 !important;
  
}
.menu {
  font-size: 17px;
  // display: inline-block;
  width: 300px;
  height: 100%;
  padding: 5px;
  box-sizing: border-box;
  background-color: rgba(255, 255, 255, 0.1);
  overflow: auto;
  .chatNum{
      color: #333;
      font-weight: 200;
      font-size: 14px;
      text-align: center;
  }
  .Box {
    box-sizing: border-box;
    width: 100%;
    height: 55px;
    box-sizing: border-box;
    background-color: #ffffff;
    border-radius: 10px;
    margin: 5px 0;
    padding: 6px;
    display: flex;
    &:hover{
    background-color: rgb(217,236,255);
  }
    .leftItem {
      margin-right: 5px;
      img {
        width: 40px;
        height: 40px;
        border-radius: 40px;
      }
    }
    .rightItem {
      color: #333;
      font-size: 12px;
      overflow: hidden;
      // text-overflow: ellipsis;
      // white-space: nowrap;
      p{
        font-weight: 200;
        overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      }
    }
  }
}
</style>